#ifndef									__QTASYNCTCPSOCKET_H__
#	define								__QTASYNCTCPSOCKET_H__

#	include								<QtNetwork/QTcpSocket>
#	include								<qobject.h>
#	include								"AAsyncTcpSocket.h"
#	include								"byte.h"
#	include								"Processor.h"

class									QtAsyncTcpSocket : public QObject, AAsyncTcpSocket
{
	Q_OBJECT

public:
	QtAsyncTcpSocket(Processor &);
	virtual ~QtAsyncTcpSocket();

public:
	virtual void						connectToHost(const std::string &, const std::string &);
	virtual void						init();
	virtual size_t						write(byte*, size_t);
	virtual	void						close();
	virtual void						sendOrder(IOrder *);
	virtual std::string					getIp();

private:
	Processor							&_proc;
	QTcpSocket							_socket;
	byte								_tmp_buf[4096];
	unsigned short						_current_msg;
	unsigned short						_id;


private:
	void								onReceive(size_t);
	void								getOrderSize();


	private slots:
		void							handle_read();

};

#endif									// !__BOOSTASYNCTCPSOCKET_H__
